package com.nf.action;

import com.nf.entity.WarnWeathers;
import com.nf.service.WarnWeathersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class WarnWeathersAction {

    @Autowired
    private WarnWeathersService service;

    @RequestMapping("/index")
    public String index(Model model){
        List<WarnWeathers> weathersList = service.getAllWarnWeathers();
        model.addAttribute("weathersList",weathersList);
        return "index";

    }

    @RequestMapping("/delWarnWeathers")
    public String delWarnWeathers(int[] id){
        service.delWarnWeathersByIds(id);
        return "redirect:index";
    }

    @RequestMapping("/addWarnWeathers")
    public String addWarnWeathers(WarnWeathers weathers){
        service.addWarnWeathers( weathers );
        return "redirect:index";
    }
}
